<template>
	<div style="width: 100%;">
		<div style="height:80px;background-color: #42B983;">
			搜索框
			<div id="">
			<el-input v-model="input" style="width: 240px" placeholder="Please input" />
			</div>
		</div>
		<!-- 我的订单{{data.order}} -->
		<div id="">
			<el-table :data="data.order" style="width: 100%" border lazy>
			    <el-table-column label="订单ID">
			      <template #default="scope">
			        <div style="display: flex; align-items: center">
			          <span style="margin-left: 10px">{{ scope.row.ordid }}</span>
			        </div>
			      </template>
			    </el-table-column>
				<el-table-column label="收货人">
				  <template #default="scope">
				    <div style="display: flex; align-items: center">
				      <span style="margin-left: 10px">{{ scope.row.ship2name }}</span>
				    </div>
				  </template>
				</el-table-column>
				<el-table-column label="收货人手机号">
				  <template #default="scope">
				    <div style="display: flex; align-items: center">
				      <span style="margin-left: 10px">{{ scope.row.ship2phone }}</span>
				    </div>
				  </template>
				</el-table-column>
				<el-table-column label="收货地址">
				  <template #default="scope">
				    <div style="display: flex; align-items: center">
				      <span style="margin-left: 10px">{{ scope.row.ship2addr }}</span>
				    </div>
				  </template>
				</el-table-column>
				<el-table-column label="发货情况">
				  <template #default="scope">
				    <div style="display: flex; align-items: center">
				      <span style="margin-left: 10px">{{status(scope.row.ship_status)}}</span>
				    </div>
				  </template>
				</el-table-column>
				<el-table-column label="创建订单时间">
				  <template #default="scope">
				    <div style="display: flex; align-items: center">
				      <span style="margin-left: 10px">{{ mydate(scope.row.tcreate) }}</span>
				    </div>
				  </template>
				</el-table-column>
			    <el-table-column label="操作">
			      <template #default="scope">
			        <el-button v-if="scope.row.ship_status==1" size="small" type="danger" @click="go2Update(scope.row.ordid)">
			          是否收货
			        </el-button>
			      </template>
			    </el-table-column>
			  </el-table>
		</div>
	</div>
</template>

<script lang="ts" setup>
	import { ref, reactive, onMounted } from 'vue'
	import { $get, $postf,$postj,$postx } from "../../ajax/index.js"
	import myalert from "../../utils/myalert.js"
	import store from "../../store/index.js"
	import { useRoute, useRouter } from 'vue-router'
	const data=reactive({
		order:[],
		orders:[],
	})
	
	onMounted(()=>{
		const fd=new FormData();
		fd.append("uid",store.state.user.uid)
		$postf("/api/seller/orditem/findOneuid",fd)
		.then((resp)=>{
			console.log(resp.data.data);
			data.order=resp.data.data;
		})
	})
	/* 日期格式化 */
	function mydate(d){
		d=new Date(d);
		console.log(d)
		console.log( typeof d)
		let yy= d.getFullYear();
		let mm= d.getMonth()+1;
		let dd=d.getDate();
		let b=yy+"年"+mm+"月"+dd+"日";
		return b;
	}
	// 显示发货情况
	function status(st){
		if(st==0)return "未发货";
		if(st==1)return "已发货";
		if(st==2)return "已收货";
	}
	// 是否收货
	function go2Update(ordid){
		console.log(ordid)
		data.orders.ordid=ordid;
		data.orders.ship_status=2;
	const fd=new FormData();
	fd.append('ordid',ordid)
	// fd.append("ship_status",2)
	// fd.append("tsign",new Date())
	$postx("/api/seller/Receiving",data.orders)
	.then((resp)=>{
		console.log(resp.data.data)
		data.order=resp.data.data;
		ElMessage({
			message: "收货成功!!!",
			type: 'success',
		})
	})

	}
</script>

<style>
</style>
